export class Pagable {
  page: number;
  size: number;
  sort: Sort[];

  constructor(o?: any) {
    this.page = o && o.page ? o.page : 1;
    this.size = o && o.size ? o.size : 10;
    this.sort = o && o.sort ? o.sort : [];
  }

  /** 重新分页 */
  reset(): void {
    this.page = 1;
  }
}

export interface Sort {
  direction: string;
  property: string;
}

export class Page<T> {
  last: boolean;
  totalPages: number;
  totalElements: number;
  number: number;
  size: number;
  first: boolean;
  numberOfElements: number;
  content: T[];

  constructor(o?: any) {
    this.last = o && o.last ? o.last : false;
    this.totalPages = o && o.totalPages ? o.totalPages : 0;
    this.totalElements = o && o.totalElements ? o.totalElements : 0;
    this.number = o && o.number ? o.number : 0;
    this.size = o && o.size ? o.size : 0;
    this.first = o && o.first ? o.first : false;
    this.numberOfElements = o && o.numberOfElements ? o.numberOfElements : 0;
    this.content = o && o.content ? o.content : [];
  }
}
